package com.hdu.other.tanxin;

import java.util.TreeSet;

public class lc1675 {
    class Solution {
        public int minimumDeviation(int[] nums) {
             TreeSet<Integer> set = new TreeSet<>();
             for (int num : nums) {
                 if (num % 2 == 1) {
                     set.add(num * 2);
                 } else {
                     set.add(num);
                 }
             }
             int res = set.last() - set.first();
             while (set.last() % 2 == 0)
             {
                 int max = set.last();
                 set.remove(max);
                 set.add(max / 2);
                 res = Math.min(res, set.last() - set.first());
             }
             return res;
        }
    }
}
